libxl: idl: support new "private" type attribute
authorIan Jackson <ian.jackson@eu.citrix.com>
Mon, 12 Dec 2011 17:48:38 +0000 (17:48 +0000)
committerIan Jackson <ian.jackson@eu.citrix.com>
Mon, 12 Dec 2011 17:48:38 +0000 (17:48 +0000)
This provides for fields in libxl datatypes which are only present in
the C version of structures and are used only by libxl itself.  This
is useful when a libxl datatype wants to contain fields which are used
by libxl internally and which are only present in the structure to
avoid additional memory allocation inconvenience.

Signed-off-by: Ian Jackson <ian.jackson@eu.citrix.com>
Acked-by: Ian Campbell <ian.campbell@citrix.com>
Committed-by: Ian Jackson <Ian.Jackson@eu.citrix.com>
tools/libxl/gentest.py
tools/libxl/libxltypes.py
tools/python/genwrap.py

index 05e77cce5e350cf41805b31990291ff53450f129..ac7a4000608a09d3d812477e7802e601887a6348 100644 (file)
@@ -56,6 +56,8 @@ def gen_rand_init(ty, v, indent = "    ", parent = None):
         s += "%s = rand() %% 2;\n" % v
     elif ty.typename in ["char *"]:
         s += "%s = rand_str();\n" % v
+    elif ty.private:
+        pass
     elif ty.typename in handcoded:
         raise Exception("Gen for handcoded %s" % ty.typename)
     else:
index 55056c2750c696fd06797b90fead6440a8dca12a..450de88f498df74afa9435eeffb9db181bda74e2 100644 (file)
@@ -33,6 +33,8 @@ class Type(object):
         if self.passby not in [PASS_BY_VALUE, PASS_BY_REFERENCE]:
             raise ValueError
 
+        self.private = kwargs.setdefault('private', False)
+
         if typename is None: # Anonymous type
             self.typename = None
             self.rawname = None
@@ -50,7 +52,7 @@ class Type(object):
 
         self.autogenerate_dispose_fn = kwargs.setdefault('autogenerate_dispose_fn', True)
 
-        if self.typename is not None:
+        if self.typename is not None and not self.private:
             self.json_fn = kwargs.setdefault('json_fn', self.typename + "_gen_json")
         else:
             self.json_fn = kwargs.setdefault('json_fn', None)
index d0c193d26f85bdb08742787d53ac98fde235d920..a5febeeab1a9da830fd20d5375cf839bd5653087 100644 (file)
@@ -129,6 +129,8 @@ static PyObject *Py%(rawname)s_new(PyTypeObject *type, PyObject *args, PyObject
 
     l.append('static PyGetSetDef Py%s_getset[] = {'%ty.rawname)
     for f in ty.fields:
+        if f.type.private:
+            continue
         l.append('    { .name = "%s", '%f.name)
         if ty.marshal_out():
             l.append('      .get = (getter)py_%s_%s_get, '%(ty.rawname, f.name))
@@ -295,9 +297,13 @@ _hidden int genwrap__ll_set(PyObject *v, long long *val, long long mask);
 
 """ % tuple((' '.join(sys.argv),) + (os.path.split(decls)[-1:]),))
     for ty in types:
+        if ty.private:
+            continue
         if isinstance(ty, libxltypes.Aggregate):
             f.write('/* Attribute get/set functions for %s */\n'%ty.typename)
             for a in ty.fields:
+                if a.type.private:
+                    continue
                 if ty.marshal_out():
                     f.write(py_attrib_get(ty,a))
                 if ty.marshal_in():